﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AllCardManage.aspx.cs" Inherits="SDLITS.Web.Driver.AllCardManage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>会员卡重置</title>
    <link href="../js/uploadify/uploadify.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.4.1.min.js" type="text/javascript"> </script>
    <script type="text/javascript" src="../js/uploadify/jquery.uploadify-3.1.min.js"></script>
    <style type="text/css">
        .customlabel span {
            color: red;
            font-weight: bold;
        }

        .marginright {
            margin-right: 15px;
        }
    </style>

    <script src="../JS/Title_hint.js" type="text/javascript"> </script>
    <script src="../JS/jquery.min.js" type="text/javascript"> </script>
    <script src="../JS/kendo.web.min.js" type="text/javascript"></script>
    <script src="../JS/console.js" type="text/javascript"> </script>
    <script src="../JS/main.js" type="text/javascript"> </script>
    <script type="text/javascript" src="../JS/uploadify/jquery.uploadify-3.1.min.js"></script>
    <link rel="stylesheet" rev="stylesheet" type="text/css" href="/css/usbocx.css" />
    <script>
        function byId(id) {
            return document.getElementById(id);
        }
        function Init() {
            var obj = byId("CardReader1");
            //设置端口号，1表示串口1，2表示串口2，依此类推；1001表示USB，依此类推。
            obj.setPortNum(0);
        }
    </script>
</head>
<body onload="Init()">
     <object id="CardReader1" codebase="../FirstActivex.cab#version=1,3,3,1" classid="CLSID:F225795B-A882-4FBA-934C-805E1B2FBD1B" width="0" height="0">
        <param name="_Version" value="65536" />
        <param name="_ExtentX" value="2646" />
        <param name="_ExtentY" value="1323" />
        <param name="_StockProps" value="0" />
        <param name="port" value="串口1" />
        <param name="PhotoPath" value="" />
        <param name="ActivityLFrom" value="" />
        <param name="ActivityLTo" value="" />
    </object>
    <object classid="CLSID:4E16E1BD-B562-48E3-813E-DC5CA566D94C"
        codebase="../MXOTOCX.ocx" id="fpDevObj" height="0" width="0">
    </object>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" AutoSizePanelID="Panel1" />
        <f:Panel ID="Panel1" BodyPadding="5px" runat="server" AutoScroll="true" EnableCollapse="false" Title="会员卡管理" ShowBorder="false">
            <Toolbars>
                <f:Toolbar ID="spanActions" runat="server" Hidden="true">
                    <Items>
                        <f:Button runat="server" ID="lbtnAddDriverCard" Hidden="true" OnClick="lbtnAddDriverCard_Click" Text="办理驾驶员卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnAddTempCard" Hidden="true" OnClick="lbtnAddTempCard_Click" Text="办理临时卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnModifyCard" Hidden="true" OnClick="lbtnModifyCard_Click" Text="更新(换)卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnFreeCard" Hidden="true" OnClick="lbtnFreeCard_Click" Text="销卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnUpdateCard" Hidden="true" OnClick="lbtnUpdateCard_Click" Text="升级卡"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnSubmitDriver" Hidden="true" OnClick="lbtnSubmitDriver_Click" Text="提交"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="lbtnSubmitTemp" Hidden="true" OnClick="lbtnSubmitTemp_Click" Text="提交"></f:Button>
                        <f:ToolbarSeparator runat="server"></f:ToolbarSeparator>
                        <f:Button runat="server" ID="Button1" OnClick="Button1_Click" Text="取消"></f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Items>
                <f:GroupPanel ID="GroupPanel5" Title="卡功能" runat="server" Height="55px" Width="800px" EnableCollapse="false">
                    <Items>
                        <f:Panel ID="Panel2" Layout="Column" ShowHeader="false" ShowBorder="false" runat="server">
                            <Items>
                                <f:Button runat="server" ID="lbtnReadIDCard" OnClientClick="readCard()" CssClass="marginright" Text="读取身份证"></f:Button>
                                <f:Button runat="server" ID="lbtnWriteIDCard" OnClick="lbtnWriteIDCard_Click" Text="输入身份证"></f:Button>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel runat="server" Title="个人身份证信息" ID="spanIdentity" Width="800px" EnableCollapse="True">
                    <Items>
                        <f:Panel ID="Panel3" runat="server" Height="170px" Width="800px" ShowBorder="false" ShowHeader="false"
                            Layout="HBox" BoxConfigAlign="Stretch" BoxConfigPosition="Start" BoxConfigChildMargin="0 40 0 0">
                            <Items>
                                <f:Panel ID="Panel4" Title="面板1" BoxFlex="1" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm1" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:TextBox ID="lblIDNumber" Label="身份证号" runat="server" Required="true"></f:TextBox>
                                                <f:TextBox ID="lblName" Label="姓名" runat="server" Required="true"></f:TextBox>
                                                <f:TextBox ID="lblIDAddress" Label="地址" runat="server" Required="true"></f:TextBox>
                                                <f:TextBox ID="lblSex" Label="性别" runat="server" Required="true"></f:TextBox>
                                                <f:DatePicker runat="server" EnableEdit="false" Required="true" DateFormatString="yyyy-MM-dd" Label="出生年月" ID="lblBirthday"></f:DatePicker>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                                <f:Panel ID="Panel5" Title="面板2" Width="350px" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm5" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:Image Width="102px" Height="126px" runat="server" ID="imgIDShot" Label="身份证照片"></f:Image>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="spanDataList" Title="卡记录" runat="server" Hidden="true" Height="205px" Width="800px" EnableCollapse="false">
                    <Items>
                        <f:Panel ID="Panel6" Title="管理" ShowBorder="false" BodyPadding="0" ShowHeader="false" Layout="Fit" runat="server" AutoScroll="true">
                            <Items>
                                <f:Grid ID="Grid1" ShowBorder="false" PageSize="5" AllowPaging="true" EnableCheckBoxSelect="true" IsDatabasePaging="false"
                                    OnPageIndexChange="Grid1_PageIndexChange" OnRowDataBound="Grid1_RowDataBound" EnableColumnLines="true" EnableHeaderMenu="false" ShowHeader="false" Title="表格" Width="760px" runat="server"
                                    EnableCollapse="false" DataKeyNames="MemCardNo" EnableTextSelection="true">
                                    <Columns>
                                        <f:RowNumberField EnablePagingNumber="true" Width="80px" TextAlign="Center" />
                                        <f:BoundField Width="80px" DataField="MemCardNo" HeaderText="卡号" />
                                        <f:BoundField Width="60px" DataField="MemType" HeaderText="卡类型" />
                                        <f:BoundField Width="60px" DataField="StatusID" HeaderText="状态" />
                                        <f:BoundField Width="80px" DataField="RegistID" HeaderText="会员卡号" />
                                        <f:BoundField Width="80px" DataField="Name" HeaderText="会员名" />
                                        <f:BoundField Width="80px" DataField="LeftCash" HeaderText="剩余金额" />
                                        <f:BoundField Width="100px" DataField="StartDate" DataFormatString="{0:yyyy-MM-dd}" HeaderText="开始日期" />
                                        <f:BoundField Width="100px" DataField="ExpireDate" DataFormatString="{0:yyyy-MM-dd}" HeaderText="过期日期" />
                                    </Columns>
                                </f:Grid>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel runat="server" Title="个人信息" ID="dataPersonal" Hidden="true" Width="800px" EnableCollapse="True">
                    <Items>
                        <f:Panel ID="Panel7" runat="server" Width="800px" ShowBorder="false" ShowHeader="false"
                            Layout="HBox" BoxConfigAlign="Stretch" BoxConfigPosition="Start" BoxConfigChildMargin="0 40 0 0">
                            <Items>
                                <f:Panel ID="Panel8" Title="面板1" BoxFlex="1" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm2" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:TextBox ID="txtCell" Label="手机号码" Required="true" runat="server"></f:TextBox>
                                                <f:TextBox ID="txtPhone" Label="座机号码" runat="server"></f:TextBox>
                                                <f:TextArea ID="txtCustom1" Height="88px" Label="备注1" runat="server"></f:TextArea>
                                                <f:TextArea ID="txtCustom2" Height="88px" Label="备注2" runat="server"></f:TextArea>
                                                <f:Button runat="server" ID="btnGetimg" OnClientClick="return Button_GetImage()" Text="读取指纹"></f:Button>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                                <f:Panel ID="Panel9" Title="面板2" Width="350px" runat="server" BodyPadding="5px" ShowBorder="false" ShowHeader="false">
                                    <Items>
                                        <f:SimpleForm ID="SimpleForm3" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                                            <Items>
                                                <f:Image Width="102px" Height="126px" runat="server" ID="imgFinger" Label="指纹照片"></f:Image>
                                            </Items>
                                        </f:SimpleForm>
                                    </Items>
                                </f:Panel>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataCard" Title="卡信息" Hidden="true" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="SimpleForm10" BodyPadding="5px" runat="server" LabelWidth="70px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>

                                        <%--<f:FileUpload runat="server" ButtonText="上传" AutoPostBack="true" OnFileSelected="file_upload_FileSelected" ButtonOnly="true" Label="上传照片" ID="file_upload"></f:FileUpload>--%>
                                        <f:Button runat="server" ID="btnCamer" Text="打开摄像头"></f:Button>
                                        <f:Image Width="102px" Height="126px" runat="server" ID="imgCam" Label="拍摄照片"></f:Image>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtMemCardNo" Label="出入卡号" Required="true" runat="server">
                                        </f:TextBox>
                                        <f:Label ID="lblMemTyp12e" Hidden="true" Label="卡类型" runat="server">
                                        </f:Label>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="lblMemType" Label="卡类型" runat="server">
                                        </f:Label>
                                        <f:TextBox ID="TextBox1" Hidden="true" Label="出入卡号" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:DatePicker ID="txtStartDate" Required="true" runat="server" EnableEdit="false" Label="开始日期"></f:DatePicker>
                                        <f:Label ID="lblExpireDate11" Hidden="true" Label="过期日期" runat="server"></f:Label>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="lblExpireDate" Label="过期日期" runat="server"></f:Label>
                                        <f:DatePicker ID="DatePicker1" Hidden="true" runat="server" EnableEdit="false" Label="开始日期"></f:DatePicker>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:Label ID="lblLeftCash" Label="剩余现金" runat="server">
                                        </f:Label>
                                        <f:TextBox ID="TextBox15" Hidden="true" Label="名称" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataDriverCardInfo" Hidden="true" Title="驾驶证信息" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="Form2" BodyPadding="5px" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtDLName" Label="驾驶员姓名" runat="server">
                                        </f:TextBox>
                                        <f:RadioButtonList ID="rbtnDLSex" Label="驾驶员性别" ColumnNumber="5" runat="server">
                                            <f:RadioItem Text="男" Value="1" Selected="true" />
                                            <f:RadioItem Text="女" Value="0" />
                                        </f:RadioButtonList>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtDLNumber" Label="驾照号码" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtDLAddress" Label="驾照地址" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
                <f:GroupPanel ID="dataRunCardInfo" Hidden="true" Title="行驶证信息" Width="800px" runat="server" EnableCollapse="True">
                    <Items>
                        <f:Form ID="Form3" BodyPadding="5px" runat="server" LabelWidth="80px" ShowBorder="False" ShowHeader="False">
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarNo" Label="车牌号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtCarEnginNo" Label="发动机号" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarIDNo" Label="车标识号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtCarOwnerName" Label="车主姓名" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtCarOwnerAddr" Label="车主地址" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="txtGCarNo" Label="挂车号码" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                            <Rows>
                                <f:FormRow ColumnWidths="50% 50%">
                                    <Items>
                                        <f:TextBox ID="txtGCarIDNo" Label="挂车标识号" runat="server">
                                        </f:TextBox>
                                        <f:TextBox ID="TextBox23" Hidden="true" Label="驾照地址" runat="server">
                                        </f:TextBox>
                                    </Items>
                                </f:FormRow>
                            </Rows>
                        </f:Form>
                    </Items>
                </f:GroupPanel>
            </Items>
        </f:Panel>
        <f:HiddenField runat="server" ID="hidMapPath1"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath1p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidIDShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath2"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath2p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidFingerShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath3"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidMapPath3p"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidCamShotTimesnap"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidCamShotName"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidFingerShotName"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidPath"></f:HiddenField>
        <f:HiddenField runat="server" ID="hidCardInfo"></f:HiddenField>
        <f:Window ID="Window1" Title="编辑" Hidden="true" EnableIFrame="true" runat="server" Target="Parent" OnClose="Window1_Close"
            IsModal="True" Width="670px" Height="360px">
        </f:Window>
        <f:Button runat="server" ID="hid_btn" OnClick="hid_btn_Click"></f:Button>
        <f:Button runat="server" ID="hid_btn1" OnClick="hid_btn1_Click"></f:Button>

    </form>
    <script type="text/javascript">

        function GetRealTime() {
            var myDate = new Date();
            return String(myDate.getFullYear()) + String(myDate.getMonth() + 1) +
                String(myDate.getDate()) + String(myDate.getHours()) + String(myDate.getMinutes()) +
                    String(myDate.getSeconds()) + String(myDate.getMilliseconds());
        }
        function getFile(path) {
            var fso, f1, s;
            fso = new ActiveXObject("Scripting.FileSystemObject");
            f1 = fso.GetFile(path);
            s = f1.OpenAsTextStream(1, 0);
            var temp = s.readAll();
            return temp;

        }
        function readCard() {
            F("<%=hidIDShotTimesnap.ClientID%>").setValue(GetRealTime());
            var hidMapPath1p = F("<%=hidMapPath1p.ClientID%>").getValue();
            var hidIDShotTimesnap = F("<%=hidIDShotTimesnap.ClientID%>").getValue();
            var lblIDNumber = F("<%=lblIDNumber.ClientID%>").getValue();
            var filepath = hidMapPath1p;
            var obj = byId("CardReader1");
            obj.Flag =0;
            //obj.PhotoPath = filepath;
            var rst = obj.ReadCard();
            var info = obj.CardNo() + "|" + obj.NameL() + "|" + obj.Address() + "|" + obj.SexL() + "|" + obj.Born();
            //  document.write(obj.PhotoPath);
            //  alert(obj.StrToJpg(obj.PhotoPath));
            // alert(info);
            F("<%=hidCardInfo.ClientID%>").setValue(info);
            __doPostBack('hid_btn1', '')
            //setTimeout(function () {
            //    __doPostBack('hid_btn1', '')
            //}, 1000);
        }

        var dwWaitTime = 5000; //超时时间（毫秒）
        var error1 = "打开指纹仪失败";
        var error2 = "用户取消操作";
        var error3 = "等待手指超时";
        var error4 = "采集图像失败";
        var error5 = "上传图像失败";
        var error6 = "提取指纹特征失败";
        var error7 = "合并指纹模板失败";

        function Button_Check_Device() {
            var bFlag = window.fpDevObj.IsMxUsbDevice();
            if (bFlag == "-1") {
                alert("连接失败");
                return;
            }
            else {
                alert("连接成功");
                return;
            }
        }
        function Button_GetImage() {
            F("<%=hidFingerShotTimesnap.ClientID%>").setValue(GetRealTime());
            var img = window.fpDevObj.mxUsbGetTz(dwWaitTime);
            if (img == "-1") {
                alert(error1);
                return false;
            }
            else if (img == "-2") {
                alert(error2);
                return false;
            }
            else if (img == "-3") {
                alert(error3);
                return false;
            }
            else if (img == "-4") {
                alert(error4);
                return false;
            }
            else if (img == "-5") {
                alert(error5);
                return false;
            }
            else {
                var hidMapPath2p = F("<%=hidMapPath2p.ClientID%>").getValue();
                var hidFingerShotTimesnap = F("<%=hidFingerShotTimesnap.ClientID%>").getValue();
                var lblIDNumber = F("<%=lblIDNumber.ClientID%>").getValue();
                var filepath = hidMapPath2p + lblIDNumber + hidFingerShotTimesnap + ".bmp";
                window.fpDevObj.mxGetTzImage(filepath);
                F("<%=hidFingerShotName.ClientID%>").setValue(lblIDNumber + hidFingerShotTimesnap + ".bmp");
                __doPostBack('hid_btn', '');

            }
    return true;
}
    </script>
</body>
</html>
